import { Button, Result } from 'antd'
import { useEffect, useState } from 'react'
import { useNavigate } from 'react-router-dom'

const RegisterResult: React.FC = () => {
    const navigate = useNavigate()
    const [count, setCount] = useState(5)
    useEffect(() => {
        const timmer = setInterval(() => {
            setCount(count - 1)
            if (count === 0) {
                navigate('/login')
            }
        }, 1000)
        return () => {
            clearInterval(timmer)
        }
    }, [count, navigate])

    return (
        <Result
            status="success"
            title="注册成功"
            subTitle={<div>{count}秒后返回登录页</div>}
            extra={[
                <Button type="primary" key="console" onClick={()=>navigate('/login')}>
                    返回登录
                </Button>
            ]}
        />
    )
}
export default RegisterResult